package cn.xi.system.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.net.URI;
import java.util.Map;

@Component
public class UrlFilter implements GlobalFilter , Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("第二个网关过滤器");
        URI uri = exchange.getRequest().getURI();
        String path = uri.getPath();
        String host = uri.getHost();
        String query = uri.getQuery();
        System.out.println(path);
        System.out.println(host);
        System.out.println(query);
        System.out.println(uri);
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
